package com.mlizhi.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Utils {
	/**
	 * 验证手机号码
	 * @param phoneNumber
	 * @return
	 */
	public static boolean matchPhoneNumber(String phoneNumber) {
		String regExp = "^(1)\\d{10}$";  
		Pattern p = Pattern.compile(regExp);  
		Matcher m = p.matcher(phoneNumber);  
		return m.find();//boolean  
	}
	
	/**
	 * 验证邮箱
	 * @param phoneNumber
	 * @return
	 */
	public static boolean matchEmail(String phoneNumber) {
		String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";    
		 Pattern regex = Pattern.compile(check);    
		 Matcher matcher = regex.matcher(phoneNumber);    
		 boolean isMatched = matcher.matches(); 
		 return isMatched;
	}
}
